﻿using Aop.Api;
using Aop.Api.Domain;
using Aop.Api.Request;
using Aop.Api.Response;
using Aop.Api.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OF.Utility.AlipayWap
{
    public class AlipayRefund
    {
        /// <summary>
        /// 支付宝退款
        /// </summary>
        /// <param name="appId">支付宝分配给开发者的应用ID</param>
        /// <param name="appPrivateKey"></param>
        /// <param name="alipayPublicKey"></param>
        /// <param name="refundObj">退款信息</param>
        /// <returns></returns>
        public static AlipayTradeRefundResponse Refund(string appId, string appPrivateKey, string alipayPublicKey, AlipayTradeRefundModel refundObj)
        {
            IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", appId, appPrivateKey, "xml", "1.0", "RSA2", alipayPublicKey, "GBK", false);
            AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
            request.SetBizModel(refundObj);
            AlipayTradeRefundResponse response = client.Execute(request);
            return response;

        }
    }
}
